cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 17)
find_package(OpenGL REQUIRED)

project(hazel)
# 在构建之前输出开始时间

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPCH_ENABLED")
set(CMAKE_CXX_PRECOMPILED_HEADER_SOURCE "pch.cpp")
set(CMAKE_CXX_PRECOMPILED_HEADER_OUTPUT "${CMAKE_BINARY_DIR}/pch.h.gch")

file (GLOB SRC_LIST_STB_IMAGE
        vendor/stb_image/*.h
        vendor/stb_image/*.cpp
)
file (GLOB SRC_LIST_IMGUI
        vendor/imgui/*.h
        vendor/imgui/*.cpp
)

file(GLOB_RECURSE SRC_LIST
        src/Hazel/*.cpp
        src/Hazel/Core/*.cpp
        src/Hazel/Debug/*.cpp
        src/Hazel/Events/*.cpp
        src/Hazel/ImGui/*.cpp
        src/Hazel/Platform/OpenGl/*.cpp
        src/Hazel/Platform/Windows/*.cpp
        src/Hazel/Renderer/*.cpp
#        src/Hazel/ImGui/ImGuiLayer.h
#        src/Hazel/Input.h
#        src/Hazel/Platform/Windows/WindowsInput.h
#        src/Hazel/KeyCodes.h
#        src/Hazel/MouseButtonCodes.h
#        src/Hazel/Renderer/GraphicsContext.h
#        src/Hazel/Platform/OpenGL/OpenGLContext.h


#        src/Hazel/Application.cpp
#        src/Hazel/Log.cpp
#        src/Hazel/Platform/Windows/WindowsWindow.cpp
#        src/Hazel/Layer.cpp
#        src/Hazel/LayerStack.cpp
#        src/Hazel/ImGui/ImGuiLayer.cpp
#        src/Hazel/Platform/Windows/WindowsInput.cpp
#        src/Hazel/Platform/OpenGL/OpenGLContext.cpp
#        src/Hazel/Renderer/Shader.cpp


        )

#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHZ_PLATFORM_WINDOWS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHZ_BUILD_DLL")
#定义全局的宏
add_definitions(-DHZ_PLATFORM_WINDOWS)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGLFW_INCLUDE_NONE")
#imgui相关
set(SRC_LIST_IMGUI_BACKENDS
        vendor/imgui/backends/imgui_impl_opengl3.h
        vendor/imgui/backends/imgui_impl_opengl3.cpp
        vendor/imgui/backends/imgui_impl_opengl3_loader.h
        vendor/imgui/backends/imgui_impl_glfw.h
        vendor/imgui/backends/imgui_impl_glfw.cpp
)

add_library(${PROJECT_NAME} STATIC ${SRC_LIST} ${SRC_LIST_IMGUI} ${SRC_LIST_IMGUI_BACKENDS}  ${SRC_LIST_STB_IMAGE})
add_subdirectory(vendor/GLFW)
add_subdirectory(vendor/Glad)
#这里链接的是cmakelist.txt文件
target_link_libraries(${PROJECT_NAME}  glfw)
target_link_libraries(${PROJECT_NAME}  glad)
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

target_include_directories(${PROJECT_NAME} PUBLIC
        vendor/spdlog/include
        vendor/GLFW/include
        vendor/Glad/include
        src/Hazel
        vendor/imgui
        vendor/imgui/backends
        vendor/glm
        vendor/stb_image
        )